<?php

require_once dirname(__FILE__) . '/../lib/usersGeneratorConfiguration.class.php';
require_once dirname(__FILE__) . '/../lib/usersGeneratorHelper.class.php';

/**
 * users actions.
 *
 * @package    my-crf
 * @subpackage users
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class usersActions extends autoUsersActions {

    public function executeBatchActivate(sfWebRequest $request) {
        $ids = $request->getParameter('ids');

        $q = Doctrine_Query::create()
                ->from('User u')
                ->whereIn('u.id', $ids);

        foreach ($q->execute() as $usuario) {
            $usuario->activate(true);
        }

        $this->getUser()->setFlash('notice', 'The selected users have been activated successfully.');

        $this->redirect('user_users');
    }

    public function executeBatchNonactivate(sfWebRequest $request) {
        $ids = $request->getParameter('ids');

        $q = Doctrine_Query::create()
                ->from('User u')
                ->whereIn('u.id', $ids);

        foreach ($q->execute() as $usuario) {
            $usuario->nonactivate(false);
        }

        $this->getUser()->setFlash('notice', 'The selected users have been Nonactivated successfully.');

        $this->redirect('user_users');
    }

    public function executeListActivate(sfWebRequest $request) {
        $xuser = $this->getRoute()->getObject();
        $xuser->activate(true);

        $this->getUser()->setFlash('notice', 'The selected users have been extended successfully.');

        $this->redirect('user_users');
    }

    public function executeListDeleteNeverActivated(sfWebRequest $request) {
        $this->getUser()->setFlash('notice', sprintf('%d never activated jobs have been deleted successfully.', $nb));

        $this->redirect('user_users');
    }

}
